Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hl.UI.chooseFile multiple select support #10788

Open
wants to merge 3 commits into
base: development
Choose a base branch
from

Conversation

nspitko
Copy link

@nspitko nspitko commented Aug 31, 2022

This is the haxe side change for HaxeFoundation/hashlink#559

This moves a bit of code around, and adds a new function hl.UI.chooseFileMultiple, which is a version of chooseFile that is always a load, and returns a path plus array of files.

The return format was chosen largely due to how the windows API works, so I'm not married to it if someone wants a different return format. I also would prefer a @:structInit class here (especially in hl) but I wanted to maintain consistency with the existing code.

Relevant API docs: https://docs.microsoft.com/en-us/windows/win32/api/commdlg/ns-commdlg-openfilenamea

Essentially this function takes the result from the hl-side chooseFile wrapper and breaks it up into a consistent haxe return. The code is fairly straightforward; we need to dig out each string in the return value, looking for the end marker (two nulls). We then handle the special case for a single file by breaking it out to keep the haxe side API consistent.

If this commit is accepted before the hashlink pull, the function will still function correctly, but not allow multiple file selections in the ui dialogue (making it basically useless, but not crashy/dangerous)

Use ucs2Length instead of trying to sniff out nulls with a byte walk.
@skial skial mentioned this pull request Aug 31, 2022
1 task
@Simn Simn added this to the Release 4.3 milestone Mar 25, 2023
@Simn Simn added the platform-hl Everything related to HashLink label Mar 25, 2023
@kLabz kLabz modified the milestones: Release 4.3, Later Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform-hl Everything related to HashLink
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants